# 容器名称
NAME=git-f
# 网桥名称
NETWORK=server-bridge
# image
IMAGE=127.0.0.1:5000/git-f:0.0.1
#build image
BUILD_IMAGE=www.tsdy.club/git-f:0.0.1
operate=$1

run() {
    docker run -itd \
    --name $NAME \
    --net=$NETWORK \
    -d $IMAGE
}

start() {
    docker container start $NAME
}

stop() {
    docker container stop $NAME
}

delete() {
    stop
    docker container rm $NAME
}

delete_image() {
    delete
    docker rmi $IMAGE
}

build() {
    docker build -t $BUILD_IMAGE .
}

push() {
    docker push $BUILD_IMAGE
}

update() {
    delete_image
    build
    run
}

if [ x$operate = x"run" ]
then
    run
elif [ x$operate = x"start" ]
then
    start
elif [ x$operate = x"stop" ]
then
    stop
elif [ x$operate = x"delete" ]
then
    delete
elif [ x$operate = x"delete-image" ]
then
    delete_image
elif [ x$operate = x"build" ]
then
    build
elif [ x$operate = x"push" ]
then
    push
elif [ x$operate = x"update" ]
then
    update
fi